<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>内容管理系统</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />

		<!-- basic styles -->

		<link href="${BASE_PATH}/static/manage/assets/css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="${BASE_PATH}/static/manage/assets/css/font-awesome.min.css" />

		<!--[if IE 7]>
		  <link rel="stylesheet" href="${BASE_PATH}/static/manage/assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

		<!-- page specific plugin styles -->

		<!-- fonts -->

		<link rel="stylesheet" href="http://fonts.useso.com/css?family=Open+Sans:400,300" />

		<!-- ace styles -->

		<link rel="stylesheet" href="${BASE_PATH}/static/manage/assets/css/ace.min.css" />
		<link rel="stylesheet" href="${BASE_PATH}/static/manage/assets/css/ace-rtl.min.css" />

		<!--[if lte IE 8]>
		  <link rel="stylesheet" href="${BASE_PATH}/static/manage/assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

		<!--[if lt IE 9]>
		<script src="${BASE_PATH}/static/manage/assets/js/html5shiv.js"></script>
		<script src="${BASE_PATH}/static/manage/assets/js/respond.min.js"></script>
		<![endif]-->
	</head>

	<body class="login-layout">
		<div class="main-container" style="margin-top:100px;">
			<div class="main-content">
				<div class="row">
					<div class="col-sm-10 col-sm-offset-1">
						<div class="login-container">
							<div class="center">
								<h1>
									<i class="icon-leaf green"></i>
									<span class="red">内容</span>
									<span class="white">管理系统</span>
								</h1>
							</div>

							<div class="space-6"></div>

							<div class="position-relative">
								<div id="login-box" class="login-box visible widget-box no-border">
									<div class="widget-body">
										<div class="widget-main">
											<h4 class="header blue lighter bigger">
												<i class="icon-coffee green"></i>
												请先登录
											</h4>

											<div class="space-6"></div>

											<form class="form-signin" id="adminForm"
												action="${BASE_PATH}/admin/login.json" autocomplete="off"
												method="post">
												<fieldset>
													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="text" name="name" class="form-control" placeholder="用户名" />
															<i class="icon-user"></i>
														</span>
													</label>

													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="password" name="password" class="form-control" placeholder="密码" />
															<i class="icon-lock"></i>
														</span>
													</label>
													
													<label class="block clearfix">
														<span class="block input-icon">
															<input type="text" name="captcha" class="form-control"
															placeholder="验证码" style="width: 100px; float: left;"> 
															<i class="icon-lock"></i>
														</span>
													</label>
													<label class="block clearfix">
														<span class="block input-icon">
															<img
															id="captcha"
															style="cursor: pointer; cursor: hand; width:150px;"
															onclick="this.src='${BASE_PATH}/admin/captcha.htm?'+Math.random();"
															src="${BASE_PATH}/admin/captcha.htm">
														</span>
													</label>
													<div class="space"></div>

													<div class="clearfix">
														<button type="submit"  class="width-35 pull-right btn btn-sm btn-primary">
															<i class="icon-key"></i>
															登录
														</button>
													</div>

													<div class="space-4"></div>
												</fieldset>
											</form>

										</div><!-- /widget-main -->

									</div><!-- /widget-body -->
								</div><!-- /login-box -->

							</div><!-- /position-relative -->
						</div>
					</div><!-- /.col -->
				</div><!-- /.row -->
			</div>
		</div><!-- /.main-container -->

		<!-- basic scripts -->

		<!--[if !IE]> -->
			<script type="text/javascript">
				window.jQuery || document.write("<script src='${BASE_PATH}/static/manage/assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
			</script>
		<!-- <![endif]-->

		<!--[if IE]>
			<script type="text/javascript">
			 window.jQuery || document.write("<script src='${BASE_PATH}/static/manage/assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
			</script>
		<![endif]-->
		<script src="${BASE_PATH}/static/manage/js/jquery.form.min.js"></script>
		<script type="text/javascript">
		/**
		 * 显示表单的错误提示
		 * @param id 表单ID
		 * @param errors 错误列表
		 */
		function showErrors(id, errors) {
			id.find('p[class=error]').hide();
			id.find('input,select').removeClass("error");
			for ( var name in errors) {
				var e = id.find('p[for=' + name + ']');
				id.find('input[name=' + name + '],select[name=' + name + ']')
						.addClass("error");
				if (e.length == 0) {
					id.find('input[name=' + name + '],select[name=' + name
									+ ']').after(
							'<p for="'+name+'" class="error"></p>');
					e = id.find('p[for=' + name + ']');
				}
				if (errors[name] != "") {
					e.html(errors[name]);
					e.show();
				}
			}
		}
		$(function() {
			$('#adminForm').ajaxForm({
				dataType : 'json',
				success : function(data) {
					if (data.result) {
						location.href = "${BASE_PATH}/manage/index.htm";
					} else {
						showErrors($('#adminForm'), data.errors);
						if (data.msg == "change_captcha") {
							$('#captcha').attr("src","${BASE_PATH}/admin/captcha.htm?"
											+ Math.random());
							$('#adminForm input[name="captcha"]').val('');
						}
					}
				}
			});
		});
	</script>
</body>
</html>
